import React, { Component } from 'react'
import Father from './Father'
// const { Provider } = createContext()
import { Provider } from '../utils/context'
// Provider  传递数据
// Consumer  使用数据

class GrandFather extends Component {
    state = {
        count: 100
    }
    render() {
        const { count } = this.state
        return (
            <div>
                <button onClick={() => {
                    this.setState({
                        count: 200
                    })
                }}>++++</button>
                <h1>我是爷爷组件 --- {count}</h1>
                {/* value == 设置要传递的数据 */}
                <Provider value={count}>
                    <Father/>
                </Provider>
            </div>
        )
    }
}

export default GrandFather

